{include file='common/head'}
<div style="overflow-x: hidden;width: 96%;margin: auto;padding-top: 1rem;height: 750px">
    <div class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label class="layui-form-label">项目负责人</label>
            <div class="layui-input-inline">
                <select name="admin_id" lay-verify="required" lay-search>
                    <option value=" "></option>
                    {foreach $admin as $val}
                    <option value="{$val.id}">{$val.admin_name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">项目名称</label>
            <div class="layui-input-inline">
                <input type="hidden" name="id" id="id" value="{$info.id}">
                <input type="text" value="{$info.project_name}" name="project_name" lay-verify="required"  class="layui-input">
            </div>
            <label class="layui-form-label">项目描述</label>
            <div class="layui-input-inline">
                <input type="text"  value="{$info.project_desc}" name="project_desc" lay-verify="required" autocomplete="No" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">预计人数</label>
            <div class="layui-input-inline">
                <input type="text"  value="{$info.project_man}" name="project_man" lay-verify="required" class="layui-input">
            </div>
            <label class="layui-form-label">项目周期/天</label>
            <div class="layui-input-inline">
                <input type="text" placeholder="" value="{$info.cycle}" name="cycle" lay-verify="required" autocomplete="No" class="layui-input">
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">开始时间</label>
            <div class="layui-input-inline">
                <input type="text" value="{$info.project_start}" id="start_time" name="project_start" autocomplete="off" placeholder="" class="layui-input">
            </div>
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-inline">
                <input type="text" value="{$info.project_end}" id="end_time" name="project_end" autocomplete="off" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
            </div>
        </div>
    </div>
</div>
{include file='common/footer'}
<script>
    layui.use('form', function(){
        var form = layui.form;

        //获取角色
        form.on('select(bank_id)', function(data){
            var bank_id=$('select[name="bank_id"] option:checked').val();
            var html='';
            $.ajax({
                url: '{:url("admin/Role/ApiGetRolePage")}',
                type: 'POST',
                async:false,
                data:{bank_id:bank_id},
                dataType:'json',
                success: function (obj) {
                    var data =obj.data;
                    $.each(data,function(i,v){
                        html+='<option value="'+v.role_id+'">'+v.name+'</option>';
                    });
                    $('select[name="role_id"]').html("<option value=''>没有内容了</option>"+html);
                    form.render('select'); //这个很重要
                }
            });
        });

        //提交表单
        var url='{:url("admin/Project/modifyProject")}';
        form.on('submit(demo1)', function(data){
            $.post(url,data.field,function (obj) {
                if(obj.code==200){
                    parent.layer.msg(obj.msg, {icon: 6,time: 1000});
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index,data.field); //再执行关闭
                }
                if(obj.code==400){
                    parent.layer.msg(obj.msg, {icon: 5,time: 1000});
                }
            },"JSON");
        });

        $('#closeIframe').click(function(){
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });

    });
</script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        var endDate= laydate.render({
            elem: '#end_time',//选择器结束时间
            type: 'datetime',
            min:"1970-1-1",//设置min默认最小值
            done: function(value,date){
                startDate.config.max={
                    year:date.year,
                    month:date.month-1,//关键
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                }
            }
        });
        //日期范围
        var startDate=laydate.render({
            elem: '#start_time',
            type: 'datetime',
            max:"2099-12-31",//设置一个默认最大值
            done: function(value, date){
                endDate.config.min ={
                    year:date.year,
                    month:date.month-1, //关键
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                };
            }
        });

    });
</script>
</body>
</html>